/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Chien
 */
@Entity
@Table(name = "TBL_WINNER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Winner.findAll", query = "SELECT w FROM Winner w"),
    @NamedQuery(name = "Winner.findByWinnerId", query = "SELECT w FROM Winner w WHERE w.winnerId = :winnerId")})
public class Winner implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "WinnerId")
    private String winnerId;
    @JoinColumn(name = "RegId", referencedColumnName = "RegId")
    @ManyToOne
    private Registration regId;
    @JoinColumn(name = "PrizeId", referencedColumnName = "PrizeId")
    @ManyToOne
    private Prize prizeId;

    public Winner() {
    }

    public Winner(String winnerId) {
        this.winnerId = winnerId;
    }

    public String getWinnerId() {
        return winnerId;
    }

    public void setWinnerId(String winnerId) {
        this.winnerId = winnerId;
    }

    public Registration getRegId() {
        return regId;
    }

    public void setRegId(Registration regId) {
        this.regId = regId;
    }

    public Prize getPrizeId() {
        return prizeId;
    }

    public void setPrizeId(Prize prizeId) {
        this.prizeId = prizeId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (winnerId != null ? winnerId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Winner)) {
            return false;
        }
        Winner other = (Winner) object;
        if ((this.winnerId == null && other.winnerId != null) || (this.winnerId != null && !this.winnerId.equals(other.winnerId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Winner[ winnerId=" + winnerId + " ]";
    }
    
}
